<template>
  <div>
    <div class="box">
      <FormPanel ref="formPanel" :list="formList" :cols="3" :labelWidth="100" formType="add" :isSubmitBtn="false" @formChange="formChangeHandle" />
    </div>
    <div>
      <LazyLoadTab v-model="activeName" :tabMenus="menus"></LazyLoadTab>
    </div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button @click="closeDialog">取 消</el-button>
    </div>
  </div>
</template>
<script>
import moment from 'moment';
import { dictionary } from '@/utils/dictMixin';
import { getFwhdXqList } from '@/api/repair/business/customer/activity.js';
export default {
  mixins: [dictionary],
  props: ['rowsData'],
  data() {
    return {
      formList: this.createFormList(),
      activeName: '活动内容',
      menus: [
        {
          title: '活动内容',
          path: 'repair/business/customer/combination/actcontent',
          params: {
            ACTIVITY_CODE: this.rowsData.ACTIVITY_CODE
          }
        },
        {
          title: '活动范围',
          path: 'repair/business/customer/combination/actscope',
          params: {
            ACTIVITY_CODE: this.rowsData.ACTIVITY_CODE
          }
        }
      ]
    };
  },
  // created (){
  //     this.FwhdMxlist(this.rowsData);
  // },
  mounted() {
    this.getFwhdXqList(this.rowsData);
  },
  methods: {
    createFormList() {
      return [
        {
          type: 'INPUT',
          label: '活动代码',
          fieldName: 'ACTIVITY_CODE',
          disabled: true,
          placeholder: ''
          // rules: [{ required: true, message: '请输入角色代码', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '活动名称',
          fieldName: 'ACTIVITY_NAME',
          disabled: true,
          placeholder: ''
          // rules: [{ required: true, message: '请输入角色名称', trigger: 'blur' }]
        },
        {
          type: 'DATE',
          label: '开始日期',
          fieldName: 'BEGIN_DATE',
          placeholder: '',
          disabled: true,
          valueFormat: 'yyyy-MM-dd'
          // itemList: this.createDictList('1278')
          // rules: [{ required: true, message: '请输入角色名称', trigger: 'blur' }]
        },
        {
          type: 'DATE',
          label: '结束日期',
          fieldName: 'END_DATE',
          placeholder: '',
          disabled: true,
          valueFormat: 'yyyy-MM-dd'
          // itemList: this.createDictList('1278')
          // rules: [{ required: true, message: '请输入角色名称', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '品牌',
          fieldName: 'BRAND',
          disabled: true,
          placeholder: '',
          itemList: []
          // rules: [{ required: true, message: '请输入角色名称', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '车系',
          fieldName: 'SERIES',
          disabled: true,
          placeholder: '',
          itemList: []
          // rules: [{ required: true, message: '请输入角色名称', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '车型',
          fieldName: 'MODEL',
          disabled: true,
          placeholder: '',
          itemList: []
          // rules: [{ required: true, message: '请输入角色名称', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '配置',
          fieldName: 'CONFIG_CODE',
          disabled: true,
          placeholder: '',
          itemList: []
          // rules: [{ required: true, message: '请输入角色名称', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '活动总金额',
          fieldName: 'ACTIVITY_AMOUNT',
          disabled: true,
          placeholder: ''
          // rules: [{ required: true, message: '请输入角色名称', trigger: 'blur' }]
        },
        {
          type: 'DATE',
          label: '行驶里程',
          fieldName: 'MILEAGE_BEGIN',
          placeholder: '',
          disabled: true,
          valueFormat: 'yyyy-MM-dd'
          // itemList: this.createDictList('1278')
          // rules: [{ required: true, message: '请输入角色名称', trigger: 'blur' }]
        },
        {
          type: 'RANGE_DATE',
          label: '销售日期',
          style: { minWidth: '200px' },
          fieldName: 'SALES_DATE_BEGIN|SALES_DATE_END',
          disabled: true
          // itemList: this.createDictList('1278')
          // rules: [{ required: true, message: '请输入角色名称', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '活动类别',
          fieldName: 'ACTIVITY_KIND',
          disabled: true,
          placeholder: '',
          itemList: this.createDictList('2003')
          // rules: [{ required: true, message: '请输入角色名称', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '车辆用途',
          fieldName: 'VEHICLE_PURPOSE',
          disabled: true,
          placeholder: '',
          itemList: []
          // rules: [{ required: true, message: '请输入角色名称', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '是否活动优先',
          fieldName: 'ACTIVITY_FIRST',
          disabled: true,
          placeholder: '',
          itemList: this.createDictList('1278')
          // rules: [{ required: true, message: '请输入角色名称', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '备件是否可编辑',
          fieldName: 'PARTS_IS_MODIFY',
          disabled: true,
          placeholder: '',
          itemList: this.createDictList('1278')
          // rules: [{ required: true, message: '请输入角色名称', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '是否备件活动',
          fieldName: 'IS_PART_ACTIVITY',
          disabled: true,
          placeholder: '',
          itemList: this.createDictList('1278')
          // rules: [{ required: true, message: '请输入角色名称', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '业务类型',
          fieldName: 'BUSINESS_TYPE',
          disabled: true,
          placeholder: '',
          itemList: this.createDictList('1394')
          // rules: [{ required: true, message: '请输入角色名称', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '活动性质',
          fieldName: 'ACTIVITY_PROPERTY',
          disabled: true,
          placeholder: '',
          itemList: this.createDictList('1196')
          // rules: [{ required: true, message: '请输入角色名称', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '年款',
          fieldName: 'MODEL_YEAR',
          disabled: true,
          placeholder: ''
          // rules: [{ required: true, message: '请输入角色名称', trigger: 'blur' }]
        },
        {
          type: 'RANGE_DATE',
          label: '保险日期',
          style: { minWidth: '200px' },
          fieldName: 'MAINTAIN_BEGIN_DATE|MAINTAIN_END_DATE',
          disabled: true
          // itemList: this.createDictList('1278')
          // rules: [{ required: true, message: '请输入角色名称', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '主题',
          fieldName: 'ACTIVITY_TITLE',
          disabled: true,
          placeholder: ''
          // rules: [{ required: true, message: '请输入角色名称', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '全球活动编号',
          fieldName: 'GLOBAL_ACTIVITY_CODE',
          disabled: true,
          placeholder: ''
          // rules: [{ required: true, message: '请输入角色名称', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '是否可多次参加活动',
          fieldName: 'IS_REPEAT_ATTEND',
          disabled: true,
          placeholder: '',
          itemList: this.createDictList('1278')
          // rules: [{ required: true, message: '请输入角色名称', trigger: 'blur' }]
        }
      ];
    },
    closeDialog() {
      this.$emit('close', false);
    },
    async getFwhdXqList(row) {
      const res = await getFwhdXqList(row);
      this.formList.forEach(x => {
        // console.log("12344",x)
        if (x.fieldName === 'ACTIVITY_KIND') {
          x.initialValue = Number(res[x.fieldName]);
        } else if (
          x.fieldName === 'BEGIN_DATE' ||
          x.fieldName === 'END_DATE' ||
          x.fieldName === 'SALES_DATE_BEGIN' ||
          x.fieldName === 'SALES_DATE_END' ||
          x.fieldName === 'MAINTAIN_BEGIN_DATE' ||
          x.fieldName === 'MAINTAIN_END_DATE'
        ) {
          x.initialValue = moment(res[x.fieldName]).format('YYYY-MM-DD');
        } else {
          x.initialValue = res[x.fieldName];
        }
      });
    }
  }
};
</script>
<style lang="less" scoped>
.box {
  border: 1px solid #ccc;
  padding-top: 15px;
  padding-right: 15px;
  border-radius: @borderRadius;
  margin-bottom: 20px;
  box-shadow: @boxShadow;
}
</style>
